<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3" xmlns:head="http://www.w3.org/1999/html">
<head th:include="public/public_css::public_css ('包装管理')"/>

<body style="background-color: #f2f2f2;">
<div class="layui-fluid larry-wrapper">
    <div class="layui-card">
        <div class="layui-row layui-col-space30">
            <div class="layui-col-xs24">
                <form class="layui-form layui-card-header  layui-card-header-auto" id="searchForm">
                    <div class="layui-inline">
                        <label class="layui-form-label">包装名称</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="bzmc" name="bzmc" placeholder="包装名称"/>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">货品编号/名称</label>
                        <input type="text" class="layui-input" id="hpmc" name="hpmc" placeholder="货品编号/名称"/>
                    </div>

                    <div class="layui-inline inline-search-btn">
                        <a class="layui-btn layui-btn-normal" data-type="reload">查询</a>
                    </div>
                </form>

                <div class="moreBtn"><i class="layui-icon layui-icon-triangle-d" style="color: #1E9FFF;"></i></div>
                <div class="group-button" id="toolbar">

                    <a class="layui-btn layui-btn-sm layui-btn-normal add-btn">
                        <i class="layui-icon">&#x1005;</i> 新增
                    </a>
                    <a class="layui-btn layui-btn-sm layui-btn-normal edit-btn">
                        <i class="layui-icon">&#x1005;</i> 修改
                    </a>
                    <a class="layui-btn layui-btn-sm layui-btn-normal out-put">
                        <i class="layui-icon">&#x1005;</i> 导出
                    </a>
                </div>
                <!--列表-->
                <section class="panel panel-padding layui-card-body">
                    <div class="pro">
                        <table id="table"></table>
                    </div>
                </section>
            </div>
        </div>
    </div>
</div>

</body>


<div th:include="/public/public_js::public_js"></div>
<style type="text/css">
    .moreBtn {
        width: 50px;
        height: 20px;
        text-align: center;
        color: #fff;
        line-height: 20px;
        background-color: #eee;
        position: relative;
        margin: 0 auto;
        cursor: pointer;
    }

    .moreBtn:before {
        content: '';
        display: block;
        width: 35px;
        height: 20px;
        position: absolute;
        transform: skewX(30deg);
        background: #eee;
        border-top-left-radius: 8px;
        left: -20px;
        top: 0;
    }

    .moreBtn:after {
        content: '';
        display: block;
        width: 35px;
        height: 20px;
        position: absolute;
        transform: skewX(-30deg);
        background: #eee;
        border-top-right-radius: 8px;
        top: 0;
        right: -20px;
    }
</style>
<script>

    layui.use(['list', 'layer', 'zzpUtils', 'jquery', 'laydate'], function () {
        window.operateEvent = {
            "click .layui-btn-primary": function (e, value, row, index) {
                /*这里激活状态那个按钮用不到，啥都不需要写，只读*/
            },
            "click #editRow": function (e, value, row, index) {//行按钮编辑  btn_stop
                editDialog(row.id);
            }
        }

        var zzpUtils = layui.zzpUtils,
            $ = layui.jquery,
            laydate = layui.laydate;

        //编辑包装
        function editDialog(id) {

                zzpUtils.dialog({
                    title: "修改包装",
                    type: 2,
                    content: "/wmsbz/editPicking?id=" + id,
                    area: ['50%', '50%'], //设置dialog大小，也可以不设置，
                    end: function () {//修改成功后刷新
                        zzpUtils.refreshTable("#table");
                    }
                });
        }


        laydate.render({
            elem: '#test5'
            , theme: '#20a0ff'
        })
        var $table = zzpUtils.table({
            elem: '#table',
            isApi: true,
            pagination: true,
            url: '/wmspacking/list',
            columns: [{
                field: '',
                checkbox: true
            }, {
                field: 'bzmc',
                title: '包装名称'
            }, {
                field: 'bzms',
                title: '包装描述'
            }, {
                field: 'zdwms',
                title: '主单位描述'
            }, {
                field: 'xsl',
                title: '箱数量'
            }, {
                field: 'tpsl',
                title: '托盘数量'
            }, {
                field: 'ti',
                title: 'TI'
            }, {
                field: 'hi',
                title: 'HI'
            }, {
                field: 'c',
                title: '长'
            }, {
                field: 'k',
                title: '宽'
            }, {
                field: 'g',
                title: '高'
            }, {
                field: 'tj',
                title: '体积'
            }, {
                field: 'zl',
                title: '重量'
            }, {
                field: 'caozuo',
                title: '操作',
                events: operateEvent,
                formatter: operateFormatter
            }],
            queryParams: function () {//查询条件
                return zzpUtils.getFormJson($("#searchForm"));
            },
            detailFormatter: function (index, row) {
                return "这里就没有确定过11";
            },
            onDblClickRow:function ( row,index) {/*双击行展示详情*/
                btn_cha(row.id);
            }
        });

        /*表格右侧按钮*/
        function operateFormatter(value, row, index) {
                return [
                    /* '<a class="layui-btn layui-btn-primary layui-btn-xs" >查看</a>',*/
                    '<a class="layui-btn layui-btn-xs" id="editRow">修改</a>'
                ].join('')
        }

        //查询
        $(".inline-search-btn").on('click', function () {
            zzpUtils.refreshTable("#table");
        })
        /*新增包装*/
        $(".add-btn").on('click', function () {
            zzpUtils.dialog({
                title: "添加包装信息",
                type: 2,
                content: "/wmsbz/addPicking",
                area: ['90%', '90%'], //设置dialog大小，也可以不设置，
                end: function () {//增加成功后刷新
                    zzpUtils.refreshTable("#table");
                }
            });
        })
        /*顶部按钮编辑包装*/
        $(".edit-btn").on('click', function () {
            var $rows = $table.bootstrapTable('getSelections');
            if ($rows.length == 1) {
                var ids = $.map($rows, function (row) {
                    return row.id;
                })
                    zzpUtils.dialog({
                        title: "修改包装信息",
                        type: 2,
                        content: "/wmsbz/editPicking?id=" + ids,
                        area: ['70%', '70%'], //设置dialog大小，也可以不设置，
                        end: function () {//修改成功后刷新
                            zzpUtils.refreshTable("#table");
                        }
                    });
            } else {
                layer.msg("请选择一条进行修改");
            }
        })

    });

    /*双击查看详情*/
    function btn_cha(id){
        var zzpUtils = layui.zzpUtils,
            $ = layui.jquery,
            laydate = layui.laydate;
        zzpUtils.dialog({
            title: "包装信息详情",
            type: 2,
            content: "/wmsbz/getFindPicking?id=" + id,
            area: ['70%', '70%'], //设置dialog大小，也可以不设置，
        });

    }
</script>
</html>